A functional correspondence between monadic evaluators and abstract machines for languages with computational effects
نویسندگان
چکیده
We extend our correspondence between evaluators and abstract machines from the pure setting of the λ-calculus to the impure setting of the computational λ-calculus. We show how to derive new abstract machines from monadic evaluators for the computational λ-calculus. Starting from (1) a generic evaluator parameterized by a monad and (2) a monad specifying a computational effect, we inline the components of the monad in the generic evaluator to obtain an evaluator written in a style that is specific to this computational effect. We then derive the corresponding abstract machine by closure-converting, CPS-transforming, and defunctionalizing this specific evaluator. We illustrate the construction with the identity monad, obtaining yet again the CEK machine, and with a lifted state monad, obtaining a variant of the CEK machine with error and state. In addition, we characterize the tail-recursive stack inspection presented by Clements and Felleisen at ESOP 2003 as a lifted state monad. This enables us to combine the stackinspection monad with other monads and to construct abstract machines for languages with properly tail-recursive stack inspection and other computational effects. The construction scales to other monads—including one more properly dedicated to stack inspection than the lifted state monad—and other monadic evaluators.
منابع مشابه
A Generic Framework for Specialization ( Abridged
We present a generic framework for specifying and implementing ooine partial evaluators. The framework provides the infrastructure for specializing higher-order programs with computational effects speciied through a monad. It performs sound specialization for all monadic instances and is evaluation-order independent. It subsumes most previously published partial evaluators for higher-order func...
متن کاملA functional correspondence between call-by-need evaluators and lazy abstract machines
We bridge the gap between compositional evaluators and abstract machines for the lambda-calculus, using closure conversion, transformation into continuation-passing style, and defunctionalization of continuations. This article is a spin-off of our article at PPDP 2003, where we consider call by name and call by value. Here, however, we consider call by need. We derive a lazy abstract machine fr...
متن کاملar X iv : 1 40 1 . 53 91 v 1 [ cs . P L ] 2 1 Ja n 20 14 The semantic marriage of monads and effects Extended abstract Dominic Orchard
Wadler and Thiemann unified type-and-effect systems with monadic semantics via a syntactic correspondence and soundness results with respect to an operational semantics. They conjecture that a general, “coherent” denotational semantics can be given to unify effect systems with a monadic-style semantics. We provide such a semantics based on the novel structure of an indexed monad, which we intro...
متن کاملFirst-order Definable String Transformations
The connection between languages defined by computational models and logic for languages is well-studied. Monadic second-order logic and finite automata are shown to closely correspond to each-other for the languages of strings, trees, and partial-orders. Similar connections are shown for first-order logic and finite automata with certain aperiodicity restriction. Courcelle in 1994 proposed a w...
متن کاملStratégies Efficaces et Modèles d'Implantation pour les Langages Fonctionnels. (Efficient Strategies and Implementation Models for Functional Languages)
In functional languages, e ciency heavily relies on the choice of an evaluation strategy and an implementation model. We rst develop a λ-calculus with explicit substitutions which avoids the usual problems of substitution and α-conversion, where we can de ne the usual strategies, as well as some strategies with more sharing of computations. We then develop an e cient implementation model for th...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید
ثبت ناماگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید
ورودعنوان ژورنال:
- Theor. Comput. Sci.
دوره 342 شماره
صفحات -
تاریخ انتشار 2005